<include file="Common/head" />
<script src="__PUBLIC__/js/weixin/mui.pullToRefresh.js?v=1.1"></script>
<script src="__PUBLIC__/js/weixin/mui.pullToRefresh.material.js?v=1.1"></script>

<div id="newsContentScroll" class="mui-content mui-scroll-wrapper">
    <div class="mui-scroll">
        <div class="index-list">
            <ul id="data-list">

            </ul>
        </div>
    </div>
</div>

<script type="text/javascript">
    var cateId = "{$cateId}";
    var curPage = 1;

    mui.init();

    mui("#newsContentScroll .mui-scroll").pullToRefresh({
        up: {
            auto: true,
            contentrefresh: '正在加载...',
            contentnomore: '',
            contentdown: '',
            callback: function() {
                loadList(this);
            }
        }
    });

    function loadList(obj) {
        mui.getJSON(apiUrl+'/News/getNewsByCate',{cate_id: cateId,p: curPage},function(cbData) {
            if (cbData.code == 200) {
                var data = cbData.data.list;
                var totalPage = parseInt(cbData.data.totalPage);
                if (isNaN(totalPage)) {
                    totalPage = 0;
                }
                if (data.length > 0) {
                    var html = '';
                    mui.each(data, function (index, item) {
                        html += '<li data-id="'+item.id+'">';
                        html += '<div class="text mui-ellipsis">'+item.title+'</div>';
                        html += '<div class="time">'+baseTool.formatDate(item.create_time,"yyyy-MM-dd")+'</div>';
                        html += '</div>';
                        html += '</li>';
                    });
                    $("#data-list").append(html);
                } else {
                    if (totalPage < 1) {
                        var html = '';
                        html += '<li class="nobox">';
                        html += '<img src="'+serverName+'/Public/images/no-data.png">';
                        html += '</li>';
                        $("#data-list").html(html);
                    }
                }
                var noMore = curPage < totalPage ? false : true;
                obj.endPullUpToRefresh(noMore);
                curPage = cbData.data.curPage;
            }
        });
    }

    mui("#data-list").on('tap','li',function(){
        var id = this.getAttribute("data-id");
        location.href = serverName+"/WeiXin/Info/detail/id/"+id;
    });
</script>
<include file="Common/footer" />